
class Topics {
    constructor(params) {
        this.topics = {}
    }

    addTopic(name) {
        if (undefined === this.topics[name]) {
            this.topics[name] = Math.random()
        }else{
            console.log("已存在");
        }
    }

    getTopic(name) {
        if (undefined === this.topics[name]) {
            this.topics[name] =  Math.random()
        }
        return this.topics[name]
    }


}

let t = new Topics()
console.log(t.getTopic("hi"));
console.log(t.getTopic("hi"));